package org.byqh.dqeai.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.byqh.dqeai.common.Json;
import org.byqh.dqeai.dto.PkAppRuntimeConditionDTO;
import org.byqh.dqeai.entity.PkAppRuntimeCondition;
import org.byqh.dqeai.entity.proxy.PkAppRuntimeConditionProxy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/apprcon")
@Tag(name = "系统[PkAppRuntimeCondition] - 应用运行时条件管理")
public class PkAppRuntimeConditionController extends BaseController<PkAppRuntimeCondition, PkAppRuntimeConditionProxy> {
    /**
     * 查询全部运行时状态信息列表
     */
    @GetMapping(value = "/")
    public Json<List<PkAppRuntimeConditionDTO>> list() {
        return this.listImpl(PkAppRuntimeConditionDTO.class, null);
    }

    /**
     * 查询指定类别运行时状态信息列表
     */
    @GetMapping(value = "/{runtimeCode}")
    public Json<List<PkAppRuntimeConditionDTO>> list(
            @PathVariable String runtimeCode) {

        return this.listImpl(PkAppRuntimeConditionDTO.class, query -> {
            return query.where(r -> r.runtimeCode().eq(runtimeCode))
                    .orderBy(r -> r.runtimeCode().asc())
                    .orderBy(r -> r.conditionSeq().asc());
        });
    }
}